/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package MODEL;

import java.io.Serializable;
import java.math.BigDecimal;
import javax.persistence.*;
import javax.xml.bind.annotation.XmlRootElement;

/**
 *
 * @author ahmed
 */
@Entity
@Table(name = "CARACTERISER")
@XmlRootElement
@NamedQueries({
    @NamedQuery(name = "Caracteriser.findAll", query = "SELECT c FROM Caracteriser c"),
    @NamedQuery(name = "Caracteriser.findByIdItem", query = "SELECT c FROM Caracteriser c WHERE c.caracteriserPK.idItem = :idItem"),
    @NamedQuery(name = "Caracteriser.findByIdCar", query = "SELECT c FROM Caracteriser c WHERE c.caracteriserPK.idCar = :idCar")})
public class Caracteriser implements Serializable {
    private static final long serialVersionUID = 1L;
    @EmbeddedId
    protected CaracteriserPK caracteriserPK;
    @JoinColumn(name = "ID_CAR", referencedColumnName = "ID_CAR", insertable = false, updatable = false)
    @ManyToOne(optional = false)
    private Caracteristique caracteristique;

    public Caracteriser() {
    }

    public Caracteriser(CaracteriserPK caracteriserPK) {
        this.caracteriserPK = caracteriserPK;
    }

    public Caracteriser(BigDecimal idItem, BigDecimal idCar) {
        this.caracteriserPK = new CaracteriserPK(idItem, idCar);
    }

    public CaracteriserPK getCaracteriserPK() {
        return caracteriserPK;
    }

    public void setCaracteriserPK(CaracteriserPK caracteriserPK) {
        this.caracteriserPK = caracteriserPK;
    }

    public Caracteristique getCaracteristique() {
        return caracteristique;
    }

    public void setCaracteristique(Caracteristique caracteristique) {
        this.caracteristique = caracteristique;
    }

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (caracteriserPK != null ? caracteriserPK.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof Caracteriser)) {
            return false;
        }
        Caracteriser other = (Caracteriser) object;
        if ((this.caracteriserPK == null && other.caracteriserPK != null) || (this.caracteriserPK != null && !this.caracteriserPK.equals(other.caracteriserPK))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return "MODEL.Caracteriser[ caracteriserPK=" + caracteriserPK + " ]";
    }
    
}
